

//
//  LGOrderBottomCell.m
//  LuxuryGoods
//
//  Created by DCQ on 2018/7/23.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGOrderBottomCell.h"
#import "OrderListModel.h"
@interface LGOrderBottomCell()
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIButton *OrderBtn;
@property (assign, nonatomic) OrderBottomStyle orderStyle;
@property (assign, nonatomic) ViewType type;
@property (copy, nonatomic) NSString  *orderId;
@end
@implementation LGOrderBottomCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)setupOrderData:(id)data withViewType:(ViewType)type{
    self.type = type;
    OrderModel * model = data;
    self.orderId =[NSString stringWithFormat:@"%@",model.order_id];
    //订单状态 0-待付款 10-待发货 20-待收货 30-待评价 40-已完成 50-退款中 51-退款被拒绝 60 -退款成功 90-已取消
    NSString * stateStr = @"";
    BOOL  btnHidden = NO;
    switch ([model.status integerValue]) {
        case 0:
            stateStr = @"立即支付";
            self.orderStyle = OrderBottomStyle_waitPayment;
            break;
        case 10:
            if (self.type == ViewType_Identification || self.type == ViewType_maintenance ) {
                stateStr = @"填写寄件物流";
                 self.orderStyle = OrderBottomStyle_waitSend;
            }else if( self.type == ViewType_Re || self.type == ViewType_Con){
                stateStr = @"填写寄件物流";
                self.orderStyle = OrderBottomStyle_completeOffer;
            }else{
                stateStr = @"";
                btnHidden = YES;
                
            }
            break;
        case 11:
            if (self.type == ViewType_Identification || self.type == ViewType_maintenance) {
                stateStr = @"查看物流";
                self.orderStyle = OrderBottomStyle_waitIdOrMtn;
            }else{
                stateStr = @"";
                btnHidden = YES;
                
            }
            break;
        case 20:
            if ( self.type == ViewType_Re || self.type == ViewType_Con) {
                stateStr = @"查看物流";
                self.orderStyle = OrderBottomStyle_completeSend;
            }else{
                stateStr = @"确认收货";
                self.orderStyle = OrderBottomStyle_waitGoods;
                
            }
            break;
        case 30:
            stateStr = @"立即评价";
            self.orderStyle = OrderBottomStyle_waitComment;
            break;
        case 40:
            stateStr = @"";
             btnHidden = YES;
            break;
        case 50:
            stateStr = @"";
            btnHidden = YES;
            break;
        case 51:
            stateStr = @"";
             btnHidden = YES;
            break;
        case 60:
            stateStr = @"";
             btnHidden = YES;
            break;
        case 90:
            stateStr = @"取消";
            btnHidden = YES;
            break;
        default:
            break;
    }
    
    [self.OrderBtn setTitle:stateStr forState:UIControlStateNormal];
    [self.OrderBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    NSString * priceStr = @"";
    if (self.type == ViewType_Con || self.type == ViewType_Re) {
        priceStr = @"";
    }else if (self.type == ViewType_AllOrders){
        
        priceStr =[NSString stringWithFormat:@"合计: %@",model.pay_price];
    }else if (self.type == ViewType_maintenance){
        priceStr =[NSString stringWithFormat:@"养护费: %@",model.pay_price];
    }else if (self.type == ViewType_Identification){
        priceStr =[NSString stringWithFormat:@"鉴定费: %@",model.pay_price];
    }
    self.priceLabel.text = priceStr;
    
}

- (void)btnAction:(id)sender{
    if (self.btnBlock) {
        self.btnBlock(self.orderStyle,self.orderId);
    }
    
}
@end
